#!/bin/bash
#

function check_nginx() {
    PORT="443"

    netstat -tunlp | grep nginx &> /dev/null 
    REVTAL=$?
    
    if [ $REVTAL -eq 0 ]; then 
        nginx_pid=`netstat -tunlp | grep nginx | grep ${PORT} | awk '{print $7}' | awk -F '/' '{print $1}'`
        echo "$(date +%Y-%m-%d" "%H:%M:%S) - - nginx service is running: ${nginx_pid}."
    else
        echo ""
    fi
}


while true; do
    check_nginx
    sleep 60s
done